<?php

$uid = $_COOKIE["id"];

if (!empty($uid)) {
    
    header("Content-Type: text/xml");
    $qid = $_GET["qid"];
    if (empty($qid)) {
        
        echo '<?xml version="1.0" encoding="utf-8 ?>"';
        echo '<Response status="1"/>';
    }
    //TODO Gerar resposta como um XML. Fica mais bonito[4] =D
    require_once("config.php");

    $con = @mysql_connect($mysql["host"] . ":" . $mysql["port"], $mysql["user"], $mysql["pass"]);

    if (!$con) {

        exit("1");
    }

    if (!@mysql_set_charset("utf8", $con)) {

        exit("1");
    }

    if (!@mysql_select_db($mysql["database"])) {

        exit("1");
    }
    
    $query = "DELETE FROM `queries` WHERE `id` = '$qid';";
    $query2 = "DELETE FROM `notification` WHERE `qid` = '$qid';";
    
    if (mysql_query($query) && mysql_query($query2)) {

        echo '<?xml version="1.0" encoding="utf-8"?>';
        echo '<Response status="0" qid="' . $qid . '"/>';
    } else {
        
        echo '<?xml version="1.0" encoding="utf-8"?>';
        echo '<Response status="2" />';
    }
} else {
    
    exit("2");
}

?>
